<h1>Testing PriorityQueue</h1>

<cfset pq = CreateObject('component','PriorityQueue').init(lengthCompare)/>

<cfoutput>
Empty Queue Size: #pq.size()#<br/>
<cfset pq.push("four")/>
<cfset pq.push("one")/>
<cfset pq.push("three")/>
3 Element size: #pq.size()#<br/>
First item: #pq.top()#<br/>
<cfset pq.pop()/>
Second item: #pq.pop()#<br/>
Third item: #pq.pop()#<br/>
Empty Queue size: #pq.size()#<br/>

<!--- TODO: Add tests using a compare method --->

</cfoutput>

	<cffunction name="lengthCompare" output="false" returntype="boolean">
		<cfargument name="A" type="any" required="true"/>
		<cfargument name="B" type="any" required="true"/>
		<cfreturn LEN(A) GT LEN(B)/>
	</cffunction>
	
	<h1>Testing with Structs</h1>
	<cfset pq = CreateObject('component','PriorityQueue').init(structCompare)/>

<cfoutput>
Empty Queue Size: #pq.size()#<br/>
<cfset a = structNew()/><cfset a.v = 17/>
<cfset b = structNew()/><cfset b.v = 2/>
<cfset c = structNew()/><cfset c.v = -2/>
<cfset pq.push(a)/>
<cfset pq.push(b)/>
<cfset pq.push(c)/>
3 Element size: #pq.size()#<br/>
First item: <cfdump var="#pq.top()#"/><br/>
<cfset pq.pop()/>
Second item: <cfdump var="#pq.pop()#"/><br/>
Third item: <cfdump var="#pq.pop()#"/><br/>
Empty Queue size: #pq.size()#<br/>

<!--- TODO: Add tests using a compare method --->

</cfoutput>

	<cffunction name="structCompare" output="false" returntype="boolean">
		<cfargument name="A" type="any" required="true"/>
		<cfargument name="B" type="any" required="true"/>
		<cfreturn A.v GT B.v/>
	</cffunction>
